package com.muqi.app.qlearn.mine;

import static nl.qbusict.cupboard.CupboardFactory.cupboard;

import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.camera2.params.RggbChannelVector;
import android.os.Bundle;
import android.provider.MediaStore.Audio.Radio;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnTouchListener;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.loopj.android.http.RequestParams;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.loader.GlideImageLoader;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.muqi.app.im.qmain.EMHelper;
import com.muqi.app.network.http.GlideImageUtils;
import com.muqi.app.network.http.MyAsyncHttp;
import com.muqi.app.network.http.ResponseUtils;
import com.muqi.app.network.http.MyAsyncHttp.AsyncCallBackListener;
import com.muqi.app.network.http.MyAsyncHttp.RESULTCODE;
import com.muqi.app.network.http.NetWorkUtils;
import com.muqi.app.network.http.ParamsUtils;
import com.muqi.app.project.contants.MContants;
import com.muqi.app.project.contants.NetWorkApi;
import com.muqi.app.project.utils.AppUtils;
import com.muqi.app.project.utils.CustomerUtil;
import com.muqi.app.project.utils.LogUtil;
import com.muqi.app.project.utils.ShowToast;
import com.muqi.app.qlearn.adapter.MyChildAdapter;
import com.muqi.app.qlearn.adapter.MyChildAdapter.OnChildDelete;
import com.muqi.app.qlearn.fragments.TabMine;
import com.muqi.app.qlearn.modles.AvatarInfo;
import com.muqi.app.qlearn.modles.ChildInfo;
import com.muqi.app.qlearn.modles.UserInfo;
import com.muqi.app.qlearn.modles.UserMobile;
import com.muqi.app.qlearn.student.BaseStudentActivity;
import com.muqi.app.qlearn.student.R;
import com.muqi.app.qlearn.student.ui.AddChildActivity;
import com.muqi.app.user.db.ChildBean;
import com.muqi.app.user.db.MyClassStudent;
import com.muqi.app.user.widget.CircularImageView;
import com.muqi.app.user.widget.MineInfoEntry;
import com.muqi.app.user.widget.MineInfoEntryText;
import com.muqi.app.user.widget.MyListView;
import com.muqi.app.utils.ChineseUtils;

public class MineInfoActivity extends BaseStudentActivity implements
		OnClickListener, OnChildDelete, OnCheckedChangeListener,
		OnDateSetListener {
	private static final int REQUEST_CODE_CONTEXT_MENU = 14;
	private MineInfoEntryText mName;

	private MineInfoEntryText mGender;
	private MineInfoEntryText mSchool;
	private CircularImageView mAvatar;
	private MineInfoEntryText mClass;
	private MineInfoEntryText mPhoneNum;
	private MineInfoEntryText mbirthDay;
	private MineInfoEntryText mNation;
	private MineInfoEntryText mFather;
	private MineInfoEntryText mMonther;
	private MineInfoEntryText mOther;
	private MineInfoEntryText mMessage;
	private RadioGroup mPhoneType;

	private ImagePicker imagePicker;
	private TextView mGenderText;
	private EditText mNameEdit;
	private LinearLayout ll_phoneType;

	private TextView mSave;

	private UserInfo userinfo;

	private MyListView listview;
	private MyChildAdapter adapter;
	private LinearLayout mLL_add;
	private List<ChildBean> childBeans;
	private int smart = 0;
	private boolean isParent = false;
	private UserMobile mobile;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mine_info);
	}

	@Override
	protected void onInit() {
		super.onInit();
		mAvatar = (CircularImageView) findViewById(R.id.user_avatar);
		ScrollView topLayout = (ScrollView) findViewById(R.id.top_layout);
		topLayout.setOnTouchListener(new OnTouchListener() {

			@SuppressLint("ClickableViewAccessibility")
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				dismissSoftKeyboard();
				return false;
			}
		});
		ll_phoneType = (LinearLayout) findViewById(R.id.ll_phoneType);
		mName = (MineInfoEntryText) findViewById(R.id.mine_name);
		mGender = (MineInfoEntryText) findViewById(R.id.mine_gender);
		mSchool = (MineInfoEntryText) findViewById(R.id.mine_school);
		mClass = (MineInfoEntryText) findViewById(R.id.mine_class);
		mPhoneNum = (MineInfoEntryText) findViewById(R.id.mine_phone_num);
		listview = (MyListView) findViewById(R.id.list);
		mLL_add = (LinearLayout) findViewById(R.id.ll_add);
		mbirthDay = (MineInfoEntryText) findViewById(R.id.mine_birtday);
		mNation = (MineInfoEntryText) findViewById(R.id.mine_nation);
		mFather = (MineInfoEntryText) findViewById(R.id.mine_father);
		mMonther = (MineInfoEntryText) findViewById(R.id.mine_mother);
		mOther = (MineInfoEntryText) findViewById(R.id.mine_other);
		mMessage = (MineInfoEntryText) findViewById(R.id.mine_message);
		mPhoneType = (RadioGroup) findViewById(R.id.mine_phone_type);
		mPhoneType.setOnCheckedChangeListener(this);
		mSave = (TextView) findViewById(R.id.mine_save);

		mAvatar.setOnClickListener(this);
		mGender.setOnClickListener(this);
		mSchool.setOnClickListener(this);
		mClass.setOnClickListener(this);
		mPhoneNum.setOnClickListener(this);
		mLL_add.setOnClickListener(this);
		mSave.setOnClickListener(this);
		mbirthDay.setOnClickListener(this);

		mGenderText = (TextView) mGender.findViewById(R.id.name);
		mNameEdit = (EditText) mName.findViewById(R.id.name);
		mName.setTitle("姓名");
		mGender.setTitle("性别");
		mGender.setIconVisibility(View.VISIBLE);
		mSchool.setTitle("学校");
		mClass.setTitle("班级");
		mPhoneNum.setTitle("手机账号");

		mbirthDay.setTitle("生日");

		mNation.setTitle("民族");
		mNation.setHint("请输入民族");

		mFather.setTitle("父亲联系电话");
		mFather.setHint("请输入联系人电话");

		mMonther.setTitle("母亲联系电话");
		mMonther.setHint("请输入联系人电话");

		mOther.setTitle("其他联系电话");
		mOther.setHint("请输入联系人电话");

		mMessage.setTitle("消息接受电话");
		mMessage.setHint("请输入联系人电话");
		initListener();
	}

	private void initListener() {
		

	}

	@Override
	protected void onData() {
		super.onData();
		userinfo = CustomerUtil.getUserInfo(this);

		imagePicker = ImagePicker.getInstance();
		imagePicker.setImageLoader(new GlideImageLoader());
		imagePicker.setShowCamera(true);
		imagePicker.setCrop(true);
		imagePicker.setSaveRectangle(true);
		imagePicker.setMultiMode(false);
		int width = (int) TypedValue.applyDimension(
				TypedValue.COMPLEX_UNIT_DIP, 250, getResources()
						.getDisplayMetrics());
		int height = (int) TypedValue.applyDimension(
				TypedValue.COMPLEX_UNIT_DIP, 250, getResources()
						.getDisplayMetrics());
		imagePicker.setFocusHeight(height);
		imagePicker.setFocusWidth(width);

		if (userinfo != null) {
			if (MContants.LOGIN_AS_PARENTS.equals(userinfo.user_type)) {
				isParent = true;
				mName.setEditable(true);
				mName.setHint("请输入姓名");
				ll_phoneType.setVisibility(View.GONE);
				mSchool.setVisibility(View.GONE);
				mClass.setVisibility(View.GONE);
				mbirthDay.setVisibility(View.GONE);
				mNation.setVisibility(View.GONE);
				mFather.setVisibility(View.GONE);
				mMonther.setVisibility(View.GONE);
				mOther.setVisibility(View.GONE);
				mMessage.setVisibility(View.GONE);
				childBeans = myChildren;
				adapter = new MyChildAdapter(mContext, childBeans, true);
				adapter.setChildDelete(this);
				listview.setAdapter(adapter);
			} else {
				isParent = false;
				loadMobileData();
				listview.setVisibility(View.GONE);
				mLL_add.setVisibility(View.GONE);
			}
			if (userinfo.avatarInfo != null
					&& !TextUtils.isEmpty(userinfo.avatarInfo.fileurl_01)) {
				mAvatar.setBorderWidth(0);
				Glide.with(this).load(userinfo.avatarInfo.fileurl_01)
						.placeholder(R.drawable.default_avator).into(mAvatar);
			}
			mName.setName(userinfo.name);
			mGender.setName(ChineseUtils.getSexString(userinfo.sex));
			mClass.setName(mSpUtil.getClassName());
			mSchool.setName(mSpUtil.getSchoolName());
			mPhoneNum.setName(userinfo.mobile);
			if (userinfo.birthday != null) {
				mName.setName(userinfo.birthday);
			}

		}
	}

	private void updateUserInfos(final String key, final String value) {
		if (NetWorkUtils.isNetworkAvailable(this)) {
			HashMap<String, Object> setMap = new HashMap<String, Object>();
			setMap.put("token", mSpUtil.getToken());
			setMap.put("key", key);
			setMap.put("value", value);
			String requestApi = ParamsUtils.buildParams(
					NetWorkApi.UPDATE_USERINFO_API, setMap);
			MyAsyncHttp.get(this, requestApi, new AsyncCallBackListener() {

				@Override
				public void onAsyncCallBack(RESULTCODE resuleCode,
						String request, String result) {
					LogUtil.e("个人信息保存结果：" + result);

					if (resuleCode == RESULTCODE.SUCCESS) {
						if (userinfo != null) {
							if ("name".equals(key)) {
								userinfo.name = value;
								if (EMHelper.getInstance() != null
										&& EMHelper.getInstance().isLoggedIn()) {
									EMHelper.getInstance()
											.getUserProfileManager()
											.setCurrentUserNick(userinfo.name);
								}
							} else if ("sex".equals(key)) {
								userinfo.sex = value;
								if(!isParent){
									mSpUtil.setCurrentChildSex(value);
								}
							} else if ("birthday".equals(key)) {
								userinfo.birthday = value;
							}
							CustomerUtil.saveUserInfo(mContext, userinfo);
							Intent i = new Intent();
							i.setAction(TabMine.BroadAction);
							MineInfoActivity.this.sendBroadcast(i);
							if ("race".equals(key) || "name".equals(key)) {
								ShowToast.showShort(mContext, "保存成功");
								finish();
							}

						}
					}

				}
			});
		} else {
			ShowToast.showShort(this, R.string.net_break);
		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.user_avatar:
			Intent intent = new Intent(MineInfoActivity.this,
					ImageGridActivity.class);
			startActivityForResult(intent, MContants.SELECT_WECHAT_DCIM_CODE);
			break;
		case R.id.mine_gender:
			selectedGender();
			break;
		case R.id.mine_school:

			break;
		case R.id.mine_class:

			break;
		case R.id.mine_phone_num:

			break;
		case R.id.ll_add:
			startActivityForResult(
					new Intent(mContext, AddChildActivity.class), 10002);
			break;
		case R.id.mine_birtday:
			enterSelectBirthday();
			break;
		case R.id.mine_save:
			saveUserInfo();
		default:
			break;
		}
	}

	private void selectedGender() {
		AlertDialog.Builder builder = new AlertDialog.Builder(
				MineInfoActivity.this);
		builder.setTitle("请选择性别");
		final String[] sex = { "男", "女" };
		builder.setSingleChoiceItems(sex, 0,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						mGenderText.setText(sex[which]);
						dialog.dismiss();
						updateUserInfos(
								"sex",
								ChineseUtils.getSexType(mGenderText.getText()
										.toString().trim()));

					}
				});
		builder.show();
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
			if (data != null
					&& requestCode == MContants.SELECT_WECHAT_DCIM_CODE) {
				ArrayList<ImageItem> images = (ArrayList<ImageItem>) data
						.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
				if (images != null && images.size() > 0) {
					upLoadUserAvatar(images.get(0).path);
				}
			}
		} else if (requestCode == REQUEST_CODE_CONTEXT_MENU) {
			switch (resultCode) {
			case UserMenuActivity.RESULT_CODE_NAN:
				mGenderText.setText("男");
				break;
			case UserMenuActivity.RESULT_CODE_NV:
				mGenderText.setText("女");
				break;
			}
		} else if (requestCode == 10002) {
			updateChild();
		}
	}

	private void updateChild() {
		/*
		 * Intent intent = new Intent("child"); sendBroadcast(intent);
		 */
		childBeans.clear();
		showLoading();
		loadingParentsChildren();
	}

	private void upLoadUserAvatar(String headFile) {
		if (NetWorkUtils.isNetworkAvailable(this)) {
			try {
				HashMap<String, Object> sendMap = new HashMap<String, Object>();
				sendMap.put("token", mSpUtil.getToken());
				String requestData = ParamsUtils.buildParams("", sendMap);

				RequestParams params = new RequestParams();
				params.put("data", requestData);
				File file = new File(headFile);
				long avatarSize = file.length();
				if (file.exists() && avatarSize > 0) {
					params.put("uploadfile", file);
				}
				MyAsyncHttp.postAvatar(this, params,
						NetWorkApi.UPLOAD_AVATAR_API,
						new AsyncCallBackListener() {

							@Override
							public void onAsyncCallBack(RESULTCODE resuleCode,
									String request, String result) {
								LogUtil.e("上传头像后返回的结果：" + result);
								if (resuleCode == RESULTCODE.SUCCESS) {
									try {
										JSONObject resultJson = new JSONObject(
												result.toString());
										JSONObject avatarUrl = resultJson
												.getJSONObject("data");
										AvatarInfo personInfoAvatar = AvatarInfo
												.fromJson(avatarUrl);
										if(personInfoAvatar!=null){
											userinfo.avatarInfo = personInfoAvatar;
											CustomerUtil
													.saveUserInfo(
															MineInfoActivity.this,
															userinfo);

											GlideImageUtils.setAvatar(
													MineInfoActivity.this,
													personInfoAvatar.fileurl_02,
													mAvatar);
											if(!isParent){
												mSpUtil.setCurrentAva(personInfoAvatar.fileurl_02);
											}
											EMHelper.getInstance()
													.getUserProfileManager()
													.setCurrentUserAvatar(
															personInfoAvatar.fileurl_02);

											Intent i = new Intent();
											i.setAction(TabMine.BroadAction);
											sendBroadcast(i);
										}
										
									} catch (Exception e) {

									}
								}
							}
						});
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			ShowToast.showShort(this, R.string.net_break);
		}
	}

	public void onBack(View v) {
		this.finish();
	}

	@Override
	protected void onChoiceChildResult(ChildBean myChild) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onChildClick(int position) {
		deleteChild(position);

	}

	private void deleteChild(final int position) {
		if (mSpUtil.getCurrentChildId().equals(
				childBeans.get(position).child_id)) {
			showToast("您当前正以该学生查看信息，无法删除，请切换其它学生再删除");
			return;
		}
		if (NetWorkUtils.isNetworkAvailable(this)) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("token", mSpUtil.getToken());
			map.put("student_id", childBeans.get(position).child_id);
			String requestApi = ParamsUtils.buildParams(
					NetWorkApi.DELETE_CHILD_API, map);
			MyAsyncHttp.get(this, requestApi, new AsyncCallBackListener() {

				@Override
				public void onAsyncCallBack(RESULTCODE resuleCode,
						String request, String result) {
					if (resuleCode == RESULTCODE.SUCCESS) {
						cupboard().withDatabase(sqlDb).delete(
								myChildren.get(position));
						showToast("删除成功");
						sendBroadcast(new Intent("childChanged"));
						updateChild();
					} else {
						try {
							JSONObject resultJSON = new JSONObject(result);
							String str = resultJSON.getString("data");
							showToast(str);
						} catch (JSONException e) {
							e.printStackTrace();
						}
					}
				}
			});
		} else {
			ShowToast.showShort(this, R.string.net_break);
		}

	}

	/**
	 * 更像家长的学生和班级的相关信息
	 */
	private void loadingParentsChildren() {
		if (NetWorkUtils.isNetworkAvailable(this)) {
			HashMap<String, Object> sendMap = new HashMap<String, Object>();
			sendMap.put("token", mSpUtil.getToken());
			String requestUrl = ParamsUtils.buildParams(
					NetWorkApi.GET_PARENTS_CHILDREN_API, sendMap);

			MyAsyncHttp.get(this, requestUrl, new AsyncCallBackListener() {

				@Override
				public void onAsyncCallBack(RESULTCODE resuleCode,
						String request, String result) {
					hideLoading();
					if (resuleCode == RESULTCODE.SUCCESS) {
						List<ChildInfo> parentOwnStudent = ResponseUtils
								.getMyChildren(mContext, result);
						if (parentOwnStudent != null
								&& parentOwnStudent.size() > 0) {

							cupboard().withDatabase(sqlDb).delete(
									ChildBean.class, "_id < ?", "10000");// clear//
																			// old//
							// datas

							for (ChildInfo child : parentOwnStudent) {
								ChildBean dbChild = new ChildBean();
								dbChild.parent_id = mSpUtil.getUserId();
								dbChild.child_id = child.studentInfo.id;
								dbChild.id_code = "";
								dbChild.im_user_id = child.studentInfo.im_user_id;
								dbChild.name = child.studentInfo.name;
								dbChild.nickname = child.studentInfo.nickname;
								dbChild.mobile = child.studentInfo.mobile;

								dbChild.class_id = child.classInfo.class_manager_id;
								dbChild.class_name = child.classInfo.name;

								dbChild.grade_id = child.classInfo.get_gradeInof.id;
								dbChild.grade_name = child.classInfo.get_gradeInof.name;

								dbChild.school_id = child.classInfo.schoolInfo.id;
								dbChild.school_name = child.classInfo.schoolInfo.name;

								dbChild.avatar_00 = child.studentInfo.avatarInfo.fileurl_00;
								dbChild.avatar_01 = child.studentInfo.avatarInfo.fileurl_01;
								dbChild.avatar_02 = child.studentInfo.avatarInfo.fileurl_02;
								dbChild.avatar_03 = child.studentInfo.avatarInfo.fileurl_03;
								cupboard().withDatabase(sqlDb).put(dbChild);

								loadingClassMembers(
										child.classInfo.class_manager_id,
										child.classInfo.name);
							}
							List<ChildBean> temp = cupboard()
									.withDatabase(sqlDb).query(ChildBean.class)
									.list();
							childBeans.addAll(temp);
							Log.e("====", myChildren.size() + " size ");
							adapter.notifyDataSetChanged();
						}
					}
				}
			});
		} else {
			ShowToast.showShort(this, R.string.net_break);// 提示无网络
		}
	}

	private void loadingClassMembers(final String classId,
			final String className) {
		if (NetWorkUtils.isNetworkAvailable(this)) {
			HashMap<String, Object> sendMap = new HashMap<String, Object>();
			sendMap.put("token", mSpUtil.getToken());
			sendMap.put("class_id", classId);
			String requestUrl = ParamsUtils.buildParams(
					NetWorkApi.GET_CLASS_MEMBERS_API, sendMap);
			MyAsyncHttp.get(this, requestUrl, new AsyncCallBackListener() {

				@Override
				public void onAsyncCallBack(RESULTCODE resuleCode,
						String request, String result) {
					if (resuleCode == RESULTCODE.SUCCESS) {
						List<MyClassStudent> studentLists = ResponseUtils
								.getClassMembers(mContext, result, classId,
										className);
						if (studentLists != null && studentLists.size() > 0) {
							cupboard().withDatabase(sqlDb).delete(
									MyClassStudent.class, "class_id = ?",
									classId);
							for (MyClassStudent student : studentLists) {
								cupboard().withDatabase(sqlDb).put(student);
							}
						}
					}
				}
			});
		} else {
			ShowToast.showShort(this, R.string.net_break);// 提示无网络
		}
	}

	@Override
	public void onCheckedChanged(RadioGroup arg0, int arg1) {
		switch (arg1) {
		case R.id.mine_phone_konw:

			updateUserInfos("smart", "y");

			break;
		case R.id.mine_phone_unkonw:
			updateUserInfos("smart", "n");
			break;
		default:
			break;
		}

	}

	/**
	 * 选择生日
	 */
	private void enterSelectBirthday() {
		new DatePickerDialog(this, this, Calendar.getInstance().get(
				Calendar.YEAR), Calendar.getInstance().get(Calendar.MONTH),
				Calendar.getInstance().get(Calendar.DAY_OF_MONTH)).show();
	}

	@Override
	public void onDateSet(DatePicker view, int year, int monthOfYear,
			int dayOfMonth) {
		if (new Date(year - 1900, monthOfYear, dayOfMonth).after(new Date())) {
			showToast("选择日期不能大于当前的日期");
		} else {
			mbirthDay
					.setName(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
			updateUserInfos("birthday", mbirthDay.getValue());
		}

	}

	/**
	 * 加载后台的电话数据
	 */
	private void loadMobileData() {
		if (NetWorkUtils.isNetworkAvailable(this)) {
			HashMap<String, Object> setMap = new HashMap<String, Object>();
			setMap.put("token", mSpUtil.getToken());
			setMap.put("im_user_id", userinfo.im_user_id);
			String requestApi = ParamsUtils.buildParams(
					NetWorkApi.GET_USER_MOBILE, setMap);
			MyAsyncHttp.get(this, requestApi, new AsyncCallBackListener() {

				@Override
				public void onAsyncCallBack(RESULTCODE resuleCode,
						String request, String result) {

					if (resuleCode == RESULTCODE.SUCCESS) {
						 mobile = ResponseUtils.getUserMobile(
								mContext, result);
						if (mobile != null) {
							display(mobile);
						}
					}

				}
			});
		} else {
			ShowToast.showShort(this, R.string.net_break);
		}
	}

	protected void display(UserMobile mobile) {
		mbirthDay.setName(mobile.birthday);
		mFather.setName(mobile.f_mobile);
		mMonther.setName(mobile.m_mobile);
		mOther.setName(mobile.o_mobile);
		mMessage.setName(mobile.r_mobile);
		mNation.setName(mobile.race);
		if ("y".equals(mobile.smart)) {
			((RadioButton) mPhoneType.getChildAt(0)).setChecked(true);
		} else {
			((RadioButton) mPhoneType.getChildAt(1)).setChecked(true);
		}

	}

	/**
	 * 保存用户的信息
	 */
	private void saveUserInfo() {

		if (isParent) {
			if (!mName.getValue().equals(userinfo.name)) {
				updateUserInfos("name", mName.getValue());
			}
		} else {
			if(!mFather.getValue().equals(mobile.f_mobile)){
				updateUserInfos("f_mobile", mFather.getValue());
			}
			if(!mMonther.getValue().equals(mobile.m_mobile)){
				updateUserInfos("m_mobile", mMonther.getValue());
			}
			if(!mOther.getValue().equals(mobile.o_mobile)){
				updateUserInfos("o_mobile", mOther.getValue());
			}
			if(!mMessage.getValue().equals(mobile.r_mobile)){
				updateUserInfos("r_mobile", mMessage.getValue());
			}
			updateUserInfos("race", mNation.getValue());
		}
	}

}
